<div class="panel">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">类型:</label>
            <div class="layui-input-block">
                <input type="radio" lay-filter="IveSup" name="IveSup" value="投资" title="去投资" checked="checked">
                <input type="radio" lay-filter="IveSup" name="IveSup" value="赞助" title="收赞助">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">金额:</label>
            <div class="layui-input-block">
                <input type="text"  name="IveSup_bill_sum" lay-verify="title" autocomplete="off" placeholder="请输入金额" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">对象:</label>
            <div class="layui-input-block">
                <input type="text" name="bill_target" lay-verify="title" autocomplete="off" placeholder="对方QQ或联系方式(可为空)" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <textarea id="bill_comment"  type="text" style="height: 80px" name="bill_comment" lay-verify="title" class="layui-input">投资</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="bill_time" placeholder="订单时间" >
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn btn_add_bill_IveSup_save">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    var IveSup = "投资";
    $(function () {
        $.getJSON ("getConfig", function (result) {
            $("#bill_time").val(result["times"]);

        });
    });
    layui.use('form', function() {
        var form = layui.form;
        form.render();
    });
    layui.use(['form', 'jquery'], function() {
        var form = layui.form
        form.on('radio(IveSup)', function (data) {
            IveSup = data.value;
            $("#bill_comment").text(IveSup);
        });
    });
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#bill_time'
            ,format : 'yyyy-MM-dd HH:mm:ss'
        });
    });
    $(".btn_add_bill_IveSup_save").click(function () {
        var bill_mode = "支出"
            ,bill_sum = $("input[name='IveSup_bill_sum']").val()
            ,bill_target = $("input[name='bill_target']").val()
            ,bill_comment = $("#bill_comment").val()
            ,bill_time = $("#bill_time").val();
        if(bill_sum == ""){
            alert("请输入金额");
            return false;
        }
        if(IveSup == "赞助"){
            bill_mode = "收入";
        }
        $.ajax({
            type : "get"
            ,url : "AddBill"
            ,data : {
                bill_gold : "0"
                ,bill_sum : bill_sum
                ,bill_mode : bill_mode
                ,bill_target : bill_target
                ,bill_TSTM : ""
                ,bill_time : bill_time
                ,bill_comment : bill_comment
            }
            ,success:function (result) {
                if(result =="true")
                {
                    getMsg();
                    alert("成功");
                    layer.closeAll();
                }else {
                    alert("失败");
                }
            }
        });


    });
</script>